package com.zhenhe.common.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zhenhe.core.common.enums.DropDownDto;
import com.zhenhe.core.common.enums.EnumUtils;
import com.zhenhe.core.common.utils.DateUtils;

@RestController
public class EnumController {

	@RequestMapping(value="enum",method=RequestMethod.GET)
	public List<DropDownDto> getEnum(String enumName,Boolean all){
		
		return EnumUtils.getEnums(enumName,all);
	}
	
	@RequestMapping(value="yearList",method=RequestMethod.GET)
	public List<DropDownDto> getyearList(){
		List<DropDownDto> list = new ArrayList<DropDownDto>();
		DropDownDto dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()));
		dto.setName(DateUtils.getYear());
		list.add(dto);
		dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()) -1);
		dto.setName(String.valueOf((Integer.valueOf(DateUtils.getYear())-1)));
		list.add(dto);
		dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()) -2);
		dto.setName(String.valueOf((Integer.valueOf(DateUtils.getYear())-2)));
		list.add(dto);
		dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()) -3);
		dto.setName(String.valueOf((Integer.valueOf(DateUtils.getYear())-3)));
		list.add(dto);
		dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()) -4);
		dto.setName(String.valueOf((Integer.valueOf(DateUtils.getYear())-4)));
		list.add(dto);
		dto = new DropDownDto();
		dto.setId(Integer.valueOf(DateUtils.getYear()) -5);
		dto.setName(String.valueOf((Integer.valueOf(DateUtils.getYear())-5)));
		list.add(dto);
		return list;
	}
}
